package com.wangfei.lessondemo;


import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


/**
 * A simple {@link Fragment} subclass.
 */
public class BlankFragment extends Fragment {


    private TextView tv;

    //标准的写法--推荐的写法 在这里初始化
    private final  static  String TEXT="text";

    public static BlankFragment newInstance(String text){
        Bundle args=new Bundle();
        BlankFragment fragment=new BlankFragment();
        args.putString(TEXT, text);
        fragment.setArguments(args);
        return fragment;
    }


    public BlankFragment() {

    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        //创建视图
        return inflater.inflate(R.layout.fragment_blank, container, false);
    }
//普通的fragment无区别。listview 区别，setAdapter
    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        //视图创建之后调用，所有控件赋值视图全部写到这里面

        tv = (TextView) view.findViewById(R.id.pager_text);
        String s =getArguments().getString(TEXT);
        tv.setText(s);
    }
}
